﻿#pragma once

class Camera
{
	glm::mat4 m_projection;
	glm::mat4 m_view;
	glm::mat4 m_viewProj;
	
public:

	Camera() :
        m_projection(glm::mat4(1.0f)),
        m_view(glm::mat4(1.0f)),
        m_viewProj(glm::mat4(1.0f))
	{
	}

	~Camera()
	{
	}

	void Perspective(float fovy, float aspect, float zNear, float zFar)
	{
		m_projection = glm::perspective(glm::radians(fovy), aspect, zNear, zFar);
		m_viewProj = m_projection * m_view;
	}

	void Ortho(float left, float right, float bottom, float top, float zNear, float zFar)
	{
		m_projection = glm::ortho(left, right, bottom, top, zNear, zFar);
		m_viewProj = m_projection * m_view;
	}

	//返回Projection * View
	void LookAt(float eyex, float eyey, float eyez, float centerx, float centery, float centerz, float upx, float upy, float upz)
	{
		m_view = glm::lookAt<float>(glm::vec3(eyex, eyey, eyez), glm::vec3(centerx, centery, centerz), glm::vec3(upx, upy, upz));
		m_viewProj = m_projection * m_view;
	}

	void Translate(glm::vec3 translation)
	{
		m_view = glm::translate(m_view, translation);
		m_viewProj = m_projection * m_view;
	}

	void Rotate(float degrees, float x, float y, float z)
	{
		m_view = glm::rotate(m_view, glm::radians(degrees), glm::vec3(x, y, z));
		m_viewProj = m_projection * m_view;
	}

	void SetViewMatrix(glm::mat4 &m)
	{
		m_view = m;
		m_viewProj = m_projection * m_view;
	}

	inline glm::mat4 & GetProjectionMatrix()
	{
		return m_projection;
	}

	inline glm::mat4 & GetViewMatrix()
	{
		return m_view;
	}
	//返回Projection * View
	inline glm::mat4 & GetViewProjectionMatrix()
	{
		return m_viewProj;
	}
};

